import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:laos_mall/common/style/app_style.dart';
import 'package:laos_mall/common/style/extension_util.dart';
import 'package:laos_mall/common/widght/item_widget.dart';

enum ZBItemStyle {
  selectBg,
  selectCircle,
  search, //搜索   text   x
  checkAll //全选
}

class ZBItemWidget extends StatefulWidget {
  const ZBItemWidget(
      {super.key,
      required this.style,
      this.prefixItem,
      this.suffixItem,
      this.isSel = false,
      this.title = "title"});

  final ZBItemStyle style;
  final dynamic prefixItem;
  final dynamic suffixItem;
  final String title;
  final bool isSel;

  @override
  State<ZBItemWidget> createState() => _ZBItemWidgetState();
}

class _ZBItemWidgetState extends State<ZBItemWidget> {
  @override
  Widget build(BuildContext context) {
    switch (widget.style) {
      case ZBItemStyle.selectBg:
        return ItemWidget(
          prefixItem: widget.prefixItem,
          suffixItem: widget.suffixItem,
          titleStyle: TextStyle(
              color: widget.isSel ? Colors.white : AppColor.primaryColor),
        ).addContainer(
            color: widget.isSel ? AppColor.primaryColor : Colors.transparent,
            height: 34.w,
            padding: EdgeInsets.symmetric(horizontal: 20.w));
      case ZBItemStyle.selectCircle:
        return ItemWidget(
          prefixItem: widget.prefixItem ?? Text("data"),
          suffixItem: widget.suffixItem ?? Icon(Icons.check_circle,color: Colors.white,),
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
        );
      case ZBItemStyle.search:
        return ItemWidget(
          prefixItem: Text(widget.title, style: AppStyle.subtitleLightStyle),
          // suffixItem:  Icon(Icons.close,size: 18,color: AppColor.textColor1,),
          suffixItem: Image.asset(
            'ic_close'.toImgPath(),
            width: 12.w,
            height: 12.w,
          ),
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
        ).addPadding(EdgeInsets.symmetric(horizontal: 20.w));

      case ZBItemStyle.checkAll:
        return ItemWidget(
          prefixItem: widget.isSel
              ? Icon(
                  Icons.check_circle,
                  size: 16.h,
                )
              : Icon(
                  Icons.radio_button_unchecked,
                  size: 16.h,
                ),
          space: 6.w,
          suffixItem: Text("all".tr),
        );
    }
    return ItemWidget(
      prefixItem: widget.prefixItem,
      suffixItem: widget.suffixItem,
    );
    ;
  }
}
